<script setup>
import { useRouter, useRoute } from 'vue-router'
import { HomeFilled, Lightning, ChatDotRound, User } from '@element-plus/icons-vue'

const router = useRouter()
const route = useRoute()

const navigateTo = (path) => {
  router.push(path)
}
</script>

<template>
  <div class="layout-container">
    <!-- 主要内容区域 -->
    <div class="main-content">
      <slot></slot>
    </div>

    <!-- 底部导航栏 -->
    <div class="bottom-nav">
      <div class="nav-item" :class="{ active: route.path === '/' }" @click="navigateTo('/')">
        <el-icon><HomeFilled /></el-icon>
        <span>看点</span>
      </div>
      <div class="nav-item" :class="{ active: route.path === '/my-home' }" @click="navigateTo('/my-home')">
        <el-icon><Lightning /></el-icon>
        <span>我家</span>
      </div>
      <div class="nav-item" :class="{ active: route.path === '/messages' }" @click="navigateTo('/messages')">
        <el-icon><ChatDotRound /></el-icon>
        <span>消息</span>
      </div>
      <div class="nav-item" :class="{ active: route.path === '/profile' }" @click="navigateTo('/profile')">
        <el-icon><User /></el-icon>
        <span>我的</span>
      </div>
    </div>
  </div>
</template>

<style scoped>
.layout-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #F5F5DC;  /* 浅米色背景 */
}

.main-content {
  flex: 1;
  padding-bottom: 60px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #311B92;  /* 深紫色背景 */
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.15);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 1000;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.7);  /* 半透明白色 */
  font-size: 12px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  border-radius: 8px;
}

.nav-item::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 20px;
  height: 2px;
  background: #FFFFFF;
  transition: transform 0.3s ease;
  border-radius: 1px;
}

.nav-item:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.1);
}

.nav-item:hover::after {
  transform: translateX(-50%) scaleX(1);
}

.nav-item:hover .el-icon {
  color: #FFFFFF;
  transform: translateY(-2px);
}

.nav-item .el-icon {
  font-size: 24px;
  color: rgba(255, 255, 255, 0.7);  /* 半透明白色 */
  transition: all 0.3s ease;
}

.nav-item span {
  font-weight: 500;
  transition: all 0.3s ease;
}

.nav-item.active {
  color: #FFFFFF;  /* 激活状态为纯白色 */
}

.nav-item.active::after {
  transform: translateX(-50%) scaleX(1);
}

.nav-item.active .el-icon {
  color: #FFFFFF;  /* 激活状态图标为纯白色 */
  transform: translateY(-2px);
}

.nav-item.active span {
  font-weight: 600;
}
</style> 